package com.exp2.exp2;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;


//resource/META-INF/spring.factories 中注册的对应的是 configuration 文件，而不是 properties 文件
//@ComponentScan
@Configuration  //这个 Configuration 的功能，对应 spring.factories 内的自动配置
@ConditionalOnProperty(prefix = "config",name = "enable",havingValue = "true")
@EnableConfigurationProperties(LocalProperties.class)
//这些注解一定不要搞错了！！！认真看清有没有properties
class LocalAutoConfiguration {


    @Bean
    CommandLineRunner createLocalCommandLineRunner(Environment env){
        return new LocalCommandLineRunner(env);
    }


    /*@Bean
    public ApplicationListener<ApplicationReadyEvent> listener() {

        return event -> System.out.print("自定义 ApplicationReadyEvent 事件监听器!"); //这个事件监听器一定要写在config类吗？
    }*/


}
